package com.ww.java8.fp.stream;

import java.util.stream.IntStream;

public class Ranges {

	/**
	 * InStream类提供了range()方法用于生成整型序列的流。
	 * @param args
	 */
	public static void main(String[] args) {
		int result = 0;
		for (int i = 10; i < 20; i++) {
			result += i;
		}
		System.out.println(result);
		
		result = 0;
		for (int i : IntStream.range(10, 20).toArray()) {
			result += i;
		}
		System.out.println(result);
		
		// 使用流
		System.out.println(IntStream.range(10, 20).sum());
	}
}
